/*
** xfunctions3.c for  in /home/gomes_m//svn/tek2/zappy-2016-gomes_m/reseau/server
** 
** Made by mickael gomes
** Login   <gomes_m@epitech.net>
** 
** Started on  Wed Jun 26 15:22:48 2013 mickael gomes
** Last update Fri Jul 26 14:42:47 2013 mickael gomes
*/

#include		<stdio.h>
#include		<sys/resource.h>
#include		<sys/time.h>
#include		<sys/types.h>
#include		<sys/socket.h>
#include		<unistd.h>
#include		<fcntl.h>
#include		"struct.h"
#include		"prototypes.h"

int			xgetrlimit()
{
  struct rlimit		rlim;
  
  if (getrlimit(RLIMIT_NOFILE, &rlim) == -1)
    my_putstr(2, "Getrlimit Error.\n", 1);
  return (rlim.rlim_cur);
}

void			xfcntl(int sock, int flag, int arg)
{
  if (fcntl(sock, flag, arg) == -1)
    my_putstr(2, "Fcntl has failed.\n",1);
}

int			xrecv(int fd, char *buff, int len, int flag)
{
  if (recv(fd, buff, len, flag) <= 0)
    return (1);
  return (0);
}

void			xread(int fd, char *buff, int size)
{
  int			len;

  if ((len = read(fd, buff, size)) <= 0)
    my_putstr(2, "Read error.\n", 1);
  buff[len] = 0;
}
